package com.gitee.somenvm.ninerpgitem.compat

import com.gitee.somenvm.ninerpgitem.compat.attribute.AttributeBridge
import org.bukkit.entity.LivingEntity
import org.bukkit.inventory.ItemStack

/**
 * BY NineRpgItem
 * com.gitee.somenvm.ninerpgitem.compat.attribute
 *
 * @author  SomeNvM
 * @date  2022/12/12 19:07
 */
object AttributeControl {
    fun attributeAdd(entity: LivingEntity, source: String, list: List<String>) {
        AttributeBridge.INSTANCE?.addAttributes(source, entity.uniqueId, list)
        AttributeBridge.INSTANCE?.update(entity)
    }

    fun attributeTake(entity: LivingEntity, source: String) {
        AttributeBridge.INSTANCE?.removeAttributes(entity.uniqueId, source)
    }

    fun attributeUpdate(entity: LivingEntity) {
        AttributeBridge.INSTANCE?.update(entity)
    }

    fun attributeGetValue(entity: LivingEntity, keyWord: String): Number {
        return AttributeBridge.INSTANCE?.getAttributeValue(entity.uniqueId, keyWord) ?: 0.0
    }

    fun attributeGetValue(itemStack: ItemStack, keyWord: String): Number {
        return AttributeBridge.INSTANCE?.getAttributeValue(itemStack, keyWord) ?: 0.0
    }
}